var t = getApp();

Page({
    data: {
        language: "",
        countDownList: [],
        actEndTimeList: [],
        groupDetail: {},
        goodsDetail: {},
        has_many_success_member: "",
        has_many_success_member_count: "",
        member_num: "",
        info: {},
        id: "",
        showOpenGroup: !1,
        goodsInfo: {},
        goodsDescription: "",
        popPrice: 0,
        level_id: 0,
        goodsCount: 1,
        goodsId: "",
        activityId: "",
        isOpen: 0,
        status: 0,
        action: 0,
        activityTest: "",
        btnTest: "",
        btnStatus: !1,
        option_level_id: "",
        nowTime: new Date().getTime() / 1e3,
        isCheckActivity: !0
    },
    onLoad: function(i) {
        i.mid && t._setMid(i.mid), console.log(i, "参数"), this._getData();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {
        wx.showShareMenu({
            withShareTicket: !1,
            menus: [ "shareAppMessage", "shareTimeline" ]
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {
        var t = wx.getStorageSync("yz_uid"), i = "";
        return t && (i = t), {
            query: "id=".concat(this.options.id, "&mid=").concat(i)
        };
    },
    onShareAppMessage: function(t) {
        var i = wx.getStorageSync("yz_uid"), a = "";
        return i && (a = i), {
            title: "向您分享一个拼购商品",
            path: "/packageB/member/group_buy/group_buy_detail/group_buy_detail?id=" + this.options.id + "&mid=" + a
        };
    },
    _getData: function() {
        var i = this, a = t.getNetAddresss("plugin.together-purchase.api.index.getTogetherData");
        a += "&o_id=" + this.options.id + "&art=purchaseDetail", t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    i.setData({
                        info: a.data.purchaseDetail
                    }), i.checkActivity();
                    var e = "";
                    switch (a.data.purchaseDetail.state) {
                      case 0:
                        e = "待支付";
                        break;

                      case 1:
                        e = "拼购中";
                        break;

                      case 2:
                        e = "拼购成功";
                        break;

                      case 3:
                        e = "拼购失败";
                        break;

                      case 4:
                        e = "成团中";
                        break;

                      case 5:
                        e = "已退款";
                        break;

                      case 6:
                        e = "已返还爱心值";
                        break;

                      case 7:
                        e = "无效";
                    }
                    i.setData({
                        "info.statename": e
                    });
                } else wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            }
        });
    },
    checkActivity: function() {
        var i = this, a = t.getNetAddresss("plugin.together-purchase.api.index.getTogetherData");
        a += "&at_id=" + this.data.info.activity_id + "&art=checkActivity", t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 == a.result ? i.setData({
                    isCheckActivity: !0
                }) : (i.setData({
                    isCheckActivity: !1
                }), wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }));
            }
        });
    },
    joinTeam: function() {
        var i = this;
        if (this.data.isCheckActivity) if (0 != this.data.info.status) {
            var a = [];
            a.push(this.data.info.goods_id);
            var e = t.getNetAddresss("from.div-from.isDisplay");
            e += "&goods_ids=" + JSON.stringify(a), t._getNetWork({
                showToastIn: !1,
                url: e,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? a.data.status && !a.data.member_status ? wx.showModal({
                        title: "提示",
                        content: "购买此商品,请补充您的个人信息",
                        success: function(t) {
                            t.confirm ? wx.navigateTo({
                                url: "/packageB/member/address/myinfo/myinfo?tag=groupBuy_join&activityId=" + i.data.info.activity_id + "&goodsId=" + i.data.info.goods_id + "&leader_id=" + i.data.info.leader_id
                            }) : t.cancel && console.log("用户点击取消");
                        }
                    }) : wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&optionsId=0&goodsId=" + i.data.info.goods_id + "&total=1&type=groupBuy_join&at_id=" + i.data.info.activity_id + "&leader_id=" + i.data.info.leader_id
                    }) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {}
            });
        } else wx.showToast({
            title: "很抱歉，该活动已结束",
            icon: "none"
        }); else wx.showToast({
            title: "抱歉，您已超出限制条件",
            icon: "none"
        });
    },
    openGroup: function() {
        if (this.data.isCheckActivity) if (0 != this.data.info.status) {
            var i = [];
            i.push(this.data.info.goods_id);
            var a = t.getNetAddresss("from.div-from.isDisplay");
            a += "&goods_ids=" + JSON.stringify(i), t._getNetWork({
                showToastIn: !1,
                url: a,
                success: function(t) {
                    var i = t.data;
                    1 == i.result ? i.data.status && !i.data.member_status ? wx.showModal({
                        title: "提示",
                        content: "购买此商品,请补充您的个人信息",
                        success: function(t) {
                            t.confirm ? wx.navigateTo({
                                url: "/packageB/member/address/myinfo/myinfo?tag=groupBuy_open&activityId=" + this.data.info.activity_id + "&goodsId=" + this.data.info.goods_id
                            }) : t.cancel && console.log("用户点击取消");
                        }
                    }) : wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&optionsId=0&goodsId=" + this.data.info.goods_id + "&total=1&type=groupBuy_open&at_id=" + this.data.info.activity_id
                    }) : wx.showToast({
                        icon: "none",
                        title: i.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {}
            });
        } else wx.showToast({
            title: "很抱歉，该活动已结束",
            icon: "none"
        }); else wx.showToast({
            title: "抱歉，您已超出限制条件",
            icon: "none"
        });
    },
    gotoList: function() {
        wx.navigateTo({
            url: "/packageB/member/group_buy/group_buy_list/group_buy_list"
        });
    },
    gotoGoods: function() {
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + this.data.info.goods_id + "&activity_id=" + this.data.info.activity_id + "&name=group_buy"
        });
    },
    gotoOrder: function() {
        var t = this.options.id;
        wx.navigateTo({
            url: "/packageA/member/orderdetail/orderdetail?order_id=" + t + "&orderType=groupsBuy"
        });
    }
});